<%@ page pageEncoding="UTF-8" %>
<%@ page import="buscar.Servico" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'servico.label', default: 'Servico')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="showFindPage">Pesquisar</g:link></span>
        </div>
        <div class="body">
        	<div style="float: left;">
				<g:form action="find" >
					Buscar por: <g:textField name="nome" value="" />
				    <g:select from="${lojas}" name="loja.id" optionKey="id"/>
				    <g:submitButton name="Buscar"/>
				</g:form>              
        	</div>
        	<br/><br/>
        	<table>
        		<tr>
	        		<th>Nome</th>
	        		<th>Preço</th>
	        		<th>Loja</th>
	        	</tr>
			    <g:each in="${servicos}" status="status" var="servico">
			    	<tr style="background-color:${status % 2 == 0 ? 'silver' : 'white'};">
				    	<td>${servico.nome}</td> 
				    	<td>R$${servico.valor}</td>
				    	<td>${servico.loja.nome}</td>
			    	</tr>
			    </g:each>
        	</table>
        </div>
    </body>
</html>
